//
//  UIBarButtonItem+category.swift
//  DSWeiBo
//
//  Created by Frank Wang on 7/7/16.
//  Copyright © 2016 Frank Wang. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
        
        //如果在func前面加上class，就相当于OC中的＋，类方法

        class func createBarBtnItem(imageName:String,target : AnyObject? ,action : Selector) -> UIBarButtonItem{
                let Btn = UIButton()
                Btn.setImage(UIImage(named:imageName), forState: UIControlState.Normal)
                Btn.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
                Btn.sizeToFit()
                Btn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
                return UIBarButtonItem(customView: Btn)
        }
}
